﻿using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using ArgusLib.InteropServices;
using ArgusLib.FFmpeg.swscale.Interop;

namespace ArgusLib.FFmpeg.swscale
{
	public class SwsFilter : NativeWrapper<Interop.SwsFilterNative>
	{
		#region Fields
		ArgusMarshaler<SwsVector> vectorMarshaler;
		#endregion

		#region Methods
		public SwsFilter()
		{
			this.vectorMarshaler = new ArgusMarshaler<SwsVector>();
		}

		public static SwsFilter GetDefaultFilter(
			float lumaGBlur, float chromaGBlur, float lumaSharpen, float chromaSharpen,
			float chromaHShift, float chromaVShift, int verbose)
		{
			return Functions.sws_getDefaultFilter(lumaGBlur, chromaGBlur, lumaSharpen, chromaSharpen, chromaHShift, chromaVShift, verbose);
		}

		protected override void DisposeCore()
		{
			Functions.sws_freeFilter(this);
		}
		#endregion

		#region Properties
		public SwsVector LumaH
		{
			get { return this.vectorMarshaler.MarshalNativeToManaged(this.Structure.lumH); }
			set { this.Structure.lumH = this.vectorMarshaler.MarshalManagedToNative(value); }
		}

		public SwsVector LumaV
		{
			get { return this.vectorMarshaler.MarshalNativeToManaged(this.Structure.lumV); }
			set { this.Structure.lumV = this.vectorMarshaler.MarshalManagedToNative(value); }
		}

		public SwsVector ChromaH
		{
			get { return this.vectorMarshaler.MarshalNativeToManaged(this.Structure.chrH); }
			set { this.Structure.chrH = this.vectorMarshaler.MarshalManagedToNative(value); }
		}

		public SwsVector ChromaV
		{
			get { return this.vectorMarshaler.MarshalNativeToManaged(this.Structure.chrV); }
			set { this.Structure.chrV = this.vectorMarshaler.MarshalManagedToNative(value); }
		}
		#endregion
	}
}
